<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Đăng nhập trang quản lý</title>
<link rel="shortcut icon" href="../Images/Icons/SunstormLogo.gif" />
<link href="../Twitter_Bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../CSS/black-tie/jquery-ui-1.8.20.custom.css"/>
<link rel="stylesheet" type="text/css" href="../CSS/keyboard.css"/>
<link rel="stylesheet" type="text/css" href="../CSS/validationEngine.jquery.css"/>


<script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery.keyboard.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery.mousewheel.js"></script>
<script type="text/javascript" src="../Scripts/jquery.keyboard.extension-typing.js"></script>
<script type="text/javascript" src="../Scripts/jquery.validationEngine.js"></script>
<script type="text/javascript" src="../Scripts/jquery.validationEngine-vi.js"></script>



<script>
		$(function(){
				$("#formLogin").validationEngine();
		});//close jquery
		/**
		*
		* @param {jqObject} the field where the validation applies
		* @param {Array[String]} validation rules for this field
		* @param {int} rule index
		* @param {Map} form options
		* @return an error string if validation failed
		*/
		function checkSpLetter(field, rules, i, options){
			if (validText(field.val())==false) {
				// this allows to use i18 for the error msgs
				return options.allrules.validate2Spletters.alertText;
			}
		}
		function validText(value) {
			var chaos = new Array ("'"," ","--","\"");
			var sum = chaos.length;
			for (var i in chaos) {if (!Array.prototype[i]) {sum += value.lastIndexOf(chaos[i])}}
			if (sum) {
			return false;
			}
			return true;
		}
		function Cancel()
		{
			document.getElementById("txtUserName").value="";
			document.getElementById("txtPassword").value="";
		}
	</script>

<style type="text/css">
<!--
#container {
	width: 100%;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 13px;
	margin: 0px;
	height: auto;
}
#content {
	width: 100%;
}
#footer_Login {
	background-color: #f9f9f9;
	height: 50px;
	width: 100%;
	border-top-width: 1px;
	border-top-style: solid;
	border-top-color: #ddd;
	position: fixed;
	bottom: 0px;
}
#header_login {
	background-color: #f9f9f9;
	height: 50px;
	top: 0px;
	border-bottom-width: 1px;
	border-bottom-style: solid;
	border-bottom-color: #ddd;
}
#container {
	margin-right: auto;
	margin-left: auto;
}
#tbLogin {
}
#formLogin {
	margin-top: 50px;
}
#divLogin {
	width: 500px;
	margin-right: auto;
	margin-left: auto;
	background-color: #f9f9f9;
}
-->
</style>
</head>

<body>
<div id="container">
  <div id="header_login">   
  </div>
  <div id="content">
  <?php if(isset($_COOKIE["AdminUser"])) echo $_COOKIE["AdminUser"]; ?>
    <form action="process/Login_process.php" method="post" id="formLogin" >
   	  <div id="divLogin" class="thumbnail">
   	    <table id="tbLogin" width="100%" border="0" cellspacing="0" cellpadding="0" >
   	      <tr>
   	        <td colspan="2" align="center" valign="middle" style="height:140px"><img src="../Images/Icons/Sunstrom_Admin.gif" width="255" height="100" alt="logo" /></td>
          </tr>
   	      <tr class="form-horizontal" >
   	        <td align="right">Tên đăng nhập:</td>
   	        <td class="input-append">&nbsp;
            	<input name="txtUserName" type="text" value="<?php if(isset($_COOKIE["AdminUser"])) echo $_COOKIE["AdminUser"]; ?>" id="txtUserName" class="validate[required,funcCall[checkSpLetter]] vktext"  /><button class="btn vk" type="button"><img src="../Images/Icons/keyboard.png" alt="" />&nbsp; </button>
            </td>
          </tr>
          <tr><td colspan="2" height="10px"></td></tr>
   	      <tr class="form-horizontal" >
   	        <td align="right">Mật khẩu:</td>
   	        <td class="input-append">&nbsp;
   	          <input type="password" value="<?php if(isset($_COOKIE["AdminPass"])) echo $_COOKIE["AdminPass"]; ?>" name="txtPassword" id="txtPassword" class="validate[required,funcCall[checkSpLetter]] vktext" /><button class="btn vk" type="button"><img src="../Images/Icons/keyboard.png" alt="" />&nbsp;</button>
            </td>
          </tr>
           <tr>
   	        <td height="25px" ></td>
   	        <td> &nbsp;<label class="checkbox">
               <input type="checkbox" id="chkRemember" name="remember" value="1"> Ghi nhớ
                </label>
            </td>
          </tr>
          
          </tr>
   	      <tr>
   	        <td>&nbsp;</td>
   	        <td>&nbsp;<input class="submit btn btn-primary"  type="submit" name="btnLogin" id="btnLogin"  value="Đăng nhập" style="width:100px" />
            <input type="button" class="btn"  id="btnCancel" value="Hủy bỏ" style="width:100px" onclick="Cancel();" /></td>
          </tr>
           <tr>
   	        <td ></td>
   	        <td height="25px"><a href="#">Quên mật khẩu?</a>
            </td>
          <tr>
   	        <td colspan="2" height="50px">&nbsp;</td>
          </tr>
        </table>
        
         <?php
		 //session_destroy;
	if(isset($_GET["e"]))
	{
		$error=intval($_GET["e"]);
		switch($error)
		{
			case 0:
	?>
    <div class="alert alert-error">
    	    <a class="close" data-dismiss="alert" href="#">&times;</a>
            <strong>Tên đăng nhập không tồn tại!!!</strong>
    </div>
    <?php
			break;
			case 1:
	?>
     <div class="alert alert-error">
    	    <a class="close" data-dismiss="alert" href="#">&times;</a>
            <strong>Mật khẩu không chính xác!!!</strong>
    </div>
     <?php
	 		break;
			case 2:
	?>
     <div class="alert alert-error">
    	    <a class="close" data-dismiss="alert" href="#">&times;</a>
            <strong>Tài khoản chưa được kích hoạt!!!</strong>
    </div>
    
    <?php
			break;
		}	
		
	}
	?>
    
        <script>
        $(function(){
				   //-------------------------Virtual Keyboard-------------------------------------------
				$('input.vktext')
				 .keyboard({ 
						   		autoAccept : true,
							  openOn : '',
							  stayOpen : false,
							  layout : 'qwerty'
							//  position:{
							 // 		my : 'center top',
   								//	at : 'center top',
									//fo : '#container'
							 // }
				 })
				 .addTyping();
				$('button.vk').click(function(){
											 
											  $(this).parent().children("input.vktext").getkeyboard().reveal();
				// $('#txtPassword').getkeyboard().reveal();
				});
				
				//---------------------------------------end Virtual Keyboard----------------------------------------------------
				   });//clocse jquery
        </script>
   	  </div>
    </form>
    <?php  session_destroy(); ?>
  </div>
  <div id="footer_Login"></div>
</div>
</body>
</html>
